using System;

namespace OffsetPath
{
    /// <summary>
    /// penso bounding box
    /// </summary>
    public class ClassAb : ClassAk
    {
        private PuntoDueD _startPoint;
        private PuntoDueD _endPoint;

        public ClassAb()
        {
            this._endPoint = new PuntoDueD();
            this._startPoint = new PuntoDueD();
        }

        public ClassAb(ClassAb A_0)
        {
            this._endPoint = new PuntoDueD();
            this._startPoint = new PuntoDueD();
            this.GetEndPnt().e(A_0.GetEndPnt());
            this.GetStartPoint().e(A_0.GetStartPoint());
        }

        public ClassAb(PuntoDueD A_0)
        {
            this._endPoint = new PuntoDueD();
            this._startPoint = new PuntoDueD();
            this.GetEndPnt().e(A_0);
            this.GetStartPoint().e(A_0);
        }

        public ClassAb(PuntoDueD A_0, PuntoDueD A_1)
        {
            this._endPoint = new PuntoDueD();
            this._startPoint = new PuntoDueD();
            this.GetEndPnt().e(A_0);
            this.GetStartPoint().e(A_1);
        }

        public ClassAb(double x0, double A_1, double x2, double A_3)
        {
            this._endPoint = new PuntoDueD();
            this._startPoint = new PuntoDueD();
            this.GetEndPnt().X = x0;
            this.GetEndPnt().Y = A_1;
            this.GetStartPoint().X = x2;
            this.GetStartPoint().Y = A_3;
        }

        public double MethodA(ClassAb A_0)
        {
            if (this.e(A_0))
            {
                return 0.0;
            }
            if (A_0.e() > this.GetStartPoint().X)
            {
                if (A_0.k() > this.GetEndPnt().Y)
                {
                    PuntoDueD puntoDueD = new PuntoDueD(this.GetStartPoint().X, this.GetEndPnt().Y);
                    return puntoDueD.MethodC(new PuntoDueD(A_0.e(), A_0.k()));
                }
                if (A_0.f() < this.GetStartPoint().Y)
                {
                    return this.GetStartPoint().MethodC(A_0.GetEndPnt());
                }
                return (A_0.e() - this.GetStartPoint().X);
            }
            if (A_0.o() < this.GetEndPnt().X)
            {
                if (A_0.k() > this.GetEndPnt().Y)
                {
                    return this.GetEndPnt().MethodC(A_0.GetStartPoint());
                }
                if (A_0.f() < this.GetStartPoint().Y)
                {
                    PuntoDueD x2 = new PuntoDueD(this.GetEndPnt().X, this.GetStartPoint().Y);
                    return x2.MethodC(new PuntoDueD(A_0.o(), A_0.f()));
                }
                return (this.GetEndPnt().X - A_0.o());
            }
            if (A_0.k() > this.GetEndPnt().Y)
            {
                return (A_0.k() - this.GetEndPnt().Y);
            }
            return (this.GetStartPoint().Y - A_0.f());
        }

        public void MethodA(double A_0)
        {
            this.GetStartPoint().X = A_0;
        }

        public void MethodA(PuntoDueD A_0)
        {
            PuntoDueD x1 = this.GetEndPnt();
            x1.X *= A_0.X;
            PuntoDueD x2 = this.GetEndPnt();
            x2.Y *= A_0.Y;
            PuntoDueD x3 = this.GetStartPoint();
            x3.X *= A_0.X;
            PuntoDueD x4 = this.GetStartPoint();
            x4.Y *= A_0.Y;
        }

        public bool MethodA(ClassAb A_0, ClassAb A_1)
        {
            PuntoDueD puntoDueD = new PuntoDueD();
            PuntoDueD x2 = new PuntoDueD();
            puntoDueD.Y = Math.Min(this.GetEndPnt().Y, A_0.GetEndPnt().Y);
            x2.Y = Math.Max(this.GetStartPoint().Y, A_0.GetStartPoint().Y);
            puntoDueD.X = Math.Max(this.GetEndPnt().X, A_0.GetEndPnt().X);
            x2.X = Math.Min(this.GetStartPoint().X, A_0.GetStartPoint().X);
            A_1.MethodA(puntoDueD, x2);
            return A_1.q();
        }

        public void MethodA(PuntoDueD A_0, PuntoDueD A_1)
        {
            this.GetEndPnt().e(A_0);
            this.GetStartPoint().e(A_1);
        }

        public void MethodA(double A_0, double A_1, double A_2, double A_3)
        {
            this.GetEndPnt().X = A_0;
            this.GetEndPnt().Y = A_1;
            this.GetStartPoint().X = A_2;
            this.GetStartPoint().Y = A_3;
        }

        public PuntoDueD MethodB()
        {
            return this.GetStartPoint().MethodA(this.GetEndPnt());
        }

        public bool MethodB(ClassAb A_0)
        {
            return (((A_0.e() < this.GetStartPoint().X) && (A_0.o() > this.GetEndPnt().X)) && (this.GetEndPnt().Y > A_0.k()));
        }

        public void MethodB(double A_0)
        {
            PuntoDueD puntoDueD = new PuntoDueD(this.MethodB());
            this.GetStartPoint().X = ((this.GetStartPoint().X - puntoDueD.X) * A_0) + puntoDueD.X;
            this.GetEndPnt().X = ((this.GetEndPnt().X - puntoDueD.X) * A_0) + puntoDueD.X;
        }

        public void MethodB(PuntoDueD A_0)
        {
            this.GetEndPnt().e(A_0);
            this.GetStartPoint().e(A_0);
        }

        public PuntoDueD GetStartPoint()
        {
            return _startPoint;
        }

        public bool c(ClassAb A_0)
        {
            return ((((A_0.e() > this.GetEndPnt().X) && (A_0.o() < this.GetStartPoint().X)) && (A_0.k() > this.GetStartPoint().Y)) && (A_0.f() < this.GetEndPnt().Y));
        }

        public void c(double A_0)
        {
            this.GetEndPnt().X = A_0;
        }

        public override double MethodC(PuntoDueD A_0)
        {
            if (A_0.X > this.GetStartPoint().X)
            {
                if (A_0.Y > this.GetEndPnt().Y)
                {
                    return A_0.MethodC(new PuntoDueD(this.GetStartPoint().X, this.GetEndPnt().Y));
                }
                if (A_0.Y < this.GetStartPoint().Y)
                {
                    return A_0.MethodC(this.GetStartPoint());
                }
                return (A_0.X - this.GetStartPoint().X);
            }
            if (A_0.X < this.GetEndPnt().X)
            {
                if (A_0.Y > this.GetEndPnt().Y)
                {
                    return A_0.MethodC(this.GetEndPnt());
                }
                if (A_0.Y < this.GetStartPoint().Y)
                {
                    return A_0.MethodC(new PuntoDueD(this.GetEndPnt().X, this.GetStartPoint().Y));
                }
                return (this.GetEndPnt().X - A_0.X);
            }
            if (A_0.Y > this.GetEndPnt().Y)
            {
                return (A_0.Y - this.GetEndPnt().Y);
            }
            if (A_0.Y < this.GetStartPoint().Y)
            {
                return (this.GetStartPoint().Y - A_0.Y);
            }
            return 0.0;
        }

        public PuntoDueD d()
        {
            PuntoDueD puntoDueD = new PuntoDueD();
            if (Math.Abs(this.GetEndPnt().X) > Math.Abs(this.GetStartPoint().X))
            {
                puntoDueD.X = this.GetEndPnt().X;
            }
            else
            {
                puntoDueD.X = this.GetStartPoint().X;
            }
            if (Math.Abs(this.GetEndPnt().Y) > Math.Abs(this.GetStartPoint().Y))
            {
                puntoDueD.Y = this.GetEndPnt().Y;
                return puntoDueD;
            }
            puntoDueD.Y = this.GetStartPoint().Y;
            return puntoDueD;
        }

        public void d(ClassAb A_0)
        {
            this.e(A_0.GetEndPnt());
            this.e(A_0.GetStartPoint());
        }

        public void d(double A_0)
        {
            this.GetEndPnt().Y = A_0;
        }

        public bool d(PuntoDueD A_0)
        {
            return ((((A_0.X >= this.GetEndPnt().X) && (A_0.X <= this.GetStartPoint().X)) && (A_0.Y <= this.GetEndPnt().Y)) && (A_0.Y >= this.GetStartPoint().Y));
        }

        public double e()
        {
            return this.GetEndPnt().X;
        }

        public bool e(ClassAb A_0)
        {
            bool flag = (A_0.e() < this.GetStartPoint().X) && (A_0.o() > this.GetEndPnt().X);
            bool flag2 = (A_0.k() < this.GetEndPnt().Y) && (A_0.f() > this.GetStartPoint().Y);
            return (flag && flag2);
        }

        public void e(double A_0)
        {
            PuntoDueD puntoDueD = new PuntoDueD(this.MethodB());
            this.GetStartPoint().Y = ((this.GetStartPoint().Y - puntoDueD.Y) * A_0) + puntoDueD.Y;
            this.GetEndPnt().Y = ((this.GetEndPnt().Y - puntoDueD.Y) * A_0) + puntoDueD.Y;
        }

        public void e(PuntoDueD A_0)
        {
            if (A_0.X > this.GetStartPoint().X)
            {
                this.GetStartPoint().X = A_0.X;
            }
            else if (A_0.X < this.GetEndPnt().X)
            {
                this.GetEndPnt().X = A_0.X;
            }
            if (A_0.Y > this.GetEndPnt().Y)
            {
                this.GetEndPnt().Y = A_0.Y;
            }
            else if (A_0.Y < this.GetStartPoint().Y)
            {
                this.GetStartPoint().Y = A_0.Y;
            }
        }

        public double f()
        {
            return this.GetEndPnt().Y;
        }

        public override void f(ClassAb A_0)
        {
            A_0.g(this);
        }

        public void f(double A_0)
        {
            PuntoDueD puntoDueD = new PuntoDueD(this.MethodB());
            this.GetStartPoint().X = ((this.GetStartPoint().X - puntoDueD.X) * A_0) + puntoDueD.X;
            this.GetStartPoint().Y = ((this.GetStartPoint().Y - puntoDueD.Y) * A_0) + puntoDueD.Y;
            this.GetEndPnt().X = ((this.GetEndPnt().X - puntoDueD.X) * A_0) + puntoDueD.X;
            this.GetEndPnt().Y = ((this.GetEndPnt().Y - puntoDueD.Y) * A_0) + puntoDueD.Y;
        }

        ~ClassAb()
        {
        }

        public void g(ClassAb A_0)
        {
            this.GetEndPnt().X = A_0.GetEndPnt().X;
            this.GetEndPnt().Y = A_0.GetEndPnt().Y;
            this.GetStartPoint().X = A_0.GetStartPoint().X;
            this.GetStartPoint().Y = A_0.GetStartPoint().Y;
        }

        public void g(double A_0)
        {
            this.GetStartPoint().Y = A_0;
        }

        public bool h(ClassAb A_0)
        {
            return ((A_0.e() < this.GetStartPoint().X) && (A_0.o() > this.GetEndPnt().X));
        }

        public void h(double A_0)
        {
            PuntoDueD x1 = this.GetStartPoint();
            x1.X += A_0;
            PuntoDueD x5 = this.GetStartPoint();
            x5.Y -= A_0;
            PuntoDueD x6 = this.GetEndPnt();
            x6.X -= A_0;
            PuntoDueD x7 = this.GetEndPnt();
            x7.Y += A_0;
        }

        public bool i(ClassAb A_0)
        {
            return (((A_0.e() < this.GetStartPoint().X) && (A_0.o() > this.GetEndPnt().X)) && (this.GetStartPoint().Y < A_0.f()));
        }

        public void j()
        {
            this.GetEndPnt().X = 0.0;
            this.GetEndPnt().Y = 0.0;
            this.GetStartPoint().X = 0.0;
            this.GetStartPoint().Y = 0.0;
        }

        public double k()
        {
            return this.GetStartPoint().Y;
        }

        public override void k(ForseLineaClassA classA0, ClassAj A_1)
        {
            this.GetEndPnt().k(classA0, A_1);
            A_1.MethodB(this.GetStartPoint().MethodB(classA0));
            PuntoDueD puntoDueD = new PuntoDueD(this.GetStartPoint().X, this.GetEndPnt().Y);
            PuntoDueD x2 = new PuntoDueD(this.GetEndPnt().X, this.GetStartPoint().Y);
            A_1.MethodB(puntoDueD.MethodB(classA0));
            A_1.MethodB(x2.MethodB(classA0));
        }

        public double l()
        {
            return (this.GetStartPoint().X - this.GetEndPnt().X);
        }

        public override void l(ClassAtPuntoIncrementale A_0, ClassAj A_1)
        {
            this.GetEndPnt().l(A_0, A_1);
            A_1.MethodB(this.GetStartPoint().MethodA(A_0));
            PuntoDueD puntoDueD = new PuntoDueD(this.GetStartPoint().X, this.GetEndPnt().Y);
            PuntoDueD x2 = new PuntoDueD(this.GetEndPnt().X, this.GetStartPoint().Y);
            A_1.MethodB(puntoDueD.MethodA(A_0));
            A_1.MethodB(x2.MethodA(A_0));
        }

        public double n()
        {
            return (this.GetEndPnt().Y - this.GetStartPoint().Y);
        }

        public override void n(ClassAg A_0)
        {
            this.GetEndPnt().n(A_0);
            this.GetStartPoint().n(A_0);
        }

        public double o()
        {
            return this.GetStartPoint().X;
        }

        public override void o(double A_0, PuntoDueD A_1)
        {
            this.GetStartPoint().o(A_0, A_1);
            this.GetEndPnt().o(A_0, A_1);
        }

        public PuntoDueD p()
        {
            PuntoDueD puntoDueD = new PuntoDueD();
            if (Math.Abs(this.GetEndPnt().X) < Math.Abs(this.GetStartPoint().X))
            {
                puntoDueD.X = this.GetEndPnt().X;
            }
            else
            {
                puntoDueD.X = this.GetStartPoint().X;
            }
            if (Math.Abs(this.GetEndPnt().Y) < Math.Abs(this.GetStartPoint().Y))
            {
                puntoDueD.Y = this.GetEndPnt().Y;
                return puntoDueD;
            }
            puntoDueD.Y = this.GetStartPoint().Y;
            return puntoDueD;
        }

        public override void p(ClassAtPuntoIncrementale A_0)
        {
            this.GetEndPnt().p(A_0);
            this.GetStartPoint().p(A_0);
        }

        public bool q()
        {
            return ((this.GetEndPnt().X < this.GetStartPoint().X) && (this.GetEndPnt().Y > this.GetStartPoint().Y));
        }

        public override void q(ForseLineaClassA classA0)
        {
            PuntoDueD puntoDueD = new PuntoDueD(this.MethodB());
            PuntoDueD x2 = new PuntoDueD(puntoDueD);
            x2.q(classA0);
            ClassAtPuntoIncrementale classAt = new ClassAtPuntoIncrementale(puntoDueD, x2);
            this.p(classAt);
        }

        public double r()
        {
            return ((this.GetEndPnt().Y - this.GetStartPoint().Y) * (this.GetStartPoint().X - this.GetEndPnt().X));
        }

        public override void r(PuntoDueD A_0)
        {
            this.GetEndPnt().r(A_0);
            this.GetStartPoint().r(A_0);
            double a = this.GetEndPnt().X;
            double b = this.GetEndPnt().Y;
            this.GetEndPnt().e(this.GetStartPoint());
            this.GetStartPoint().X = a;
            this.GetStartPoint().Y = b;
        }

        public PuntoDueD GetEndPnt()
        {
            return _endPoint;
        }

        public override void GetStartPoint(double A_0, PuntoDueD A_1)
        {
            double num = this.l() / 2.0;
            double num2 = this.n() / 2.0;
            PuntoDueD puntoDueD = new PuntoDueD(this.MethodB());
            puntoDueD.GetStartPoint(A_0, A_1);
            this.GetEndPnt().X = puntoDueD.X - num;
            this.GetEndPnt().Y = puntoDueD.Y + num2;
            this.GetStartPoint().X = puntoDueD.X + num;
            this.GetStartPoint().Y = puntoDueD.Y - num2;
        }
    }
}

